package cn.wuqingna.legendgem.attribute

import cn.wuqingna.legendgem.attribute.imp.AttributePlus
import cn.wuqingna.legendgem.attribute.imp.NullAttribute
import cn.wuqingna.legendgem.attribute.imp.OriginAttribute
import cn.wuqingna.legendgem.util.info
import org.bukkit.Bukkit
import taboolib.common.LifeCycle
import taboolib.common.platform.Awake

import java.util.function.Consumer

object Attribute {
    var LegendAttributeAPI: IAttribute = NullAttribute

    @Awake(LifeCycle.ENABLE)
    fun init() {

        hookExecute("AttributePlus") {
            info(" &fSelect &cAttributePlus")
            LegendAttributeAPI = AttributePlus
        }
        hookExecute("OriginAttribute") {
            LegendAttributeAPI = OriginAttribute
            info(" &fSelect &cOriginAttribute")
        }

    }
    fun hookExecute(name: String?, consumer: Consumer<Void?>) {
        if (Bukkit.getPluginManager().isPluginEnabled(name!!)) {
            consumer.accept(null)
        }
    }
}